﻿/*
 *KH21E_VCAN.c
 *
 *Created on:2022-10-19 03:36:12
 *
 *Author:By BMS Developer Team
 *
 *ToolVersion: V1.0.0.9
*/


/******************************************************************************/
/*----------------------------------Includes----------------------------------*/
/******************************************************************************/
#include "VcanPacket.h"
#include "includes.h"
#include "../src/BSW/HWAbs/BmsCfg.h"

uint8_T Rte_CANRx_VCU_HVPwrCmd;           /* (娑撶粯甯寸憴锕侇嚞濮癸拷) */
uint8_T Rte_CANRx_VCU_LowPwrDownCmd;      /* (娑撳鏁哥拠閿嬬湴) */
uint16_T Rte_CANRx_OBC_ChgCurr;
uint8_T Rte_CANRx_OBC_FltSts;
uint8_T Rte_CANRx_VCU_LifeCnt = 0;
uint8_T Rte_CANRx_OBC_LifeCnt = 0;
uint8_T Rte_CANRx_FDC_LifeCnt = 0;
uint8_T Rte_CANRx_OBC_LifeCnt1 = 0;
uint8_T Rte_CANRx_FDCSts = 0;
uint8_T CANTx_Sofware_Ver = 100;
uint8_T Rte_CANRx_CCSts = 0;
uint8_T Rte_CANRx_CC1Sts = 0;
uint8_T Rte_CANRx_Obc_ChgSts = 0;
uint8_T Rte_CANRx_Obc_WakeUp = 0;
uint8_T Rte_CANRx_tDuty = 0;
uint8_T Rte_CANRx_VehicleSpeed = 0;
uint8_T Rte_CANRx_QchgAlow = 0;
uint8_T Rte_CANRx_FDCMaiPosRlySts = 0;




/******************************************************************************/
/*-------------------------Function Implementations---------------------------*/
/******************************************************************************/
//Pack

/* --------------- Pcak MessageName: BMS_1 ------------------
            *  ID(Dec)              = 402772211
            *  ID(Hex)              = 0x1801D0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 3
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1801D0F3_BMS_1(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)((Rte_CANTx_FltLvMax_GetVal()) & 0xF);
	Data[1] = Data[1] | (uint8_T)(Rte_CANTx_FltNum_GetVal());

	tempData = (uint32_T)(Rte_CANTx_FltCode_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x1801D0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_2 ------------------
            *  ID(Dec)              = 402837747
            *  ID(Hex)              = 0x1802D0F3
            *  ByteCount			= 4
            *  MessageSignalCount   = 15
            *  CycleTime            = 100
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1802D0F3_BMS_2(void)
{
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
    Data[0] = Data[0] | (uint8_T)((fltm_enum_cellOVFlt) & 0x3);
    Data[0] = Data[0] | (uint8_T)(((fltm_enum_cellUVFlt) & 0x3) << 2);
    Data[0] = Data[0] | (uint8_T)(((fltm_enum_cellOTFlt) & 0x3) << 4);
    Data[0] = Data[0] | (uint8_T)(((fltm_enum_cellOTChgFlt) & 0x3) << 6);

    Data[1] = Data[1] | (uint8_T)((fltm_enum_cellUTFlt) & 0x3);
    Data[1] = Data[1] | (uint8_T)(((fltm_enum_cellUTChgFlt) & 0x3) << 2);
    Data[1] = Data[1] | (uint8_T)(((fltm_enum_cellDiffVolFlt) & 0x3) << 4);
    Data[1] = Data[1] | (uint8_T)(((fltm_enum_cellDiffTmpFlt) & 0x3) << 6);

    Data[2] = Data[2] | (uint8_T)((fltm_enum_packOVFlt) & 0x3);
    Data[2] = Data[2] | (uint8_T)(((fltm_enum_packUVFlt) & 0x3) << 2);
    Data[2] = Data[2] | (uint8_T)(((fltm_enum_sohU) & 0x3) << 4);
    Data[2] = Data[2] | (uint8_T)(((fltm_enum_socU) & 0x3) << 6);

    Data[3] = Data[3] | (uint8_T)((fltm_enum_ChgOC) & 0x3);
    Data[3] = Data[3] | (uint8_T)(((fltm_enum_DsgOC) & 0x3) << 2);
    Data[3] = Data[3] | (uint8_T)(((fltm_enum_insuU) & 0x3) << 4);
    Data[3] = Data[3] | (uint8_T)(((fltm_enum_chgPlugOT) & 0x3) << 6);

    Data[4] = Data[4] | (uint8_T)((fltm_enum_heatOTFlt) & 0x3);
    Data[4] = Data[4] | (uint8_T)((fltm_enum_BMSHwCircuit & 0x3) << 2);
    Data[4] = Data[4] | (uint8_T)(((fltm_enum_PreFail>0? 1:0) & 0x1)<< 4);
    Data[4] = Data[4] | (uint8_T)(((0) & 0x1) << 5);
    Data[4] = Data[4] | (uint8_T)(((fltm_enum_PackVolSmpFlt>0?1:0) & 0x1) << 6);
    Data[4] = Data[4] | (uint8_T)(((fltm_enum_socO>0?1:0) & 0x1) << 7);

    Data[5] = Data[5] | (uint8_T)(((fltm_enum_CurrSmpAbnl>0)?1:0) & 0x1);
    Data[5] = Data[5] | (uint8_T)((((fltm_enum_CellVolSmpFlt>0)?1:0) & 0x1) << 1);
    Data[5] = Data[5] | (uint8_T)((((fltm_enum_CellTmpSmpFlt>0)?1:0) & 0x1) << 2);
    Data[5] = Data[5] | (uint8_T)(((0) & 0x1) << 3);
    Data[5] = Data[5] | (uint8_T)((((fltm_enum_hvilFlt>0)?1:0) & 0x1) << 4);
    Data[5] = Data[5] | (uint8_T)(((fltm_enum_PTCHeatInvalid>0?1:0) & 0x1) << 5);
    Data[5] = Data[5] | (uint8_T)(((0) & 0x1) << 6);
    Data[5] = Data[5] | (uint8_T)(((fltm_enum_socJump>0) & 0x1) << 7);

    Data[6] = Data[6] | (uint8_T)((fltm_enum_posRlyAd>0?1:0) & 0x3);
    Data[6] = Data[6] | (uint8_T)(((0) & 0x3) << 4);
    Data[6] = Data[6] | (uint8_T)(((0) & 0x3) << 6);

    Data[7] = Data[7] | (uint8_T)((0) & 0x3);
    Data[7] = Data[7] | (uint8_T)(((fltm_enum_ptcAdFlt>0?1:0) & 0x3) << 2);
    Data[7] = Data[7] | (uint8_T)((((fltm_enum_vcuComFlt>0)?1:0) & 0x1) << 4);
    Data[7] = Data[7] | (uint8_T)(((fltm_enum_BackOC) & 0x3) << 5);
    Data[7] = Data[7] | (uint8_T)((((fltm_enum_ThermRunaway>0)?1:0) & 0x1) << 7);

	VCUCAN_Send_Data(0x1802D0F3,Data,8);  //Enqueue
}
//{
//	uint32_T tempData;
//	uint8_T Data[8]={0,0,0,0,0,0,0,0};
//	Data[0] = Data[0] | (uint8_T)((Rte_CANTx_CellTempDiffFlt_GetVal()) & 0x3);
//	Data[0] = Data[0] | (uint8_T)(((Rte_CANTx_CellTempOTFlt_GetVal()) & 0x3) << 2);
//	Data[0] = Data[0] | (uint8_T)(((Rte_CANTx_PackVoltOVFlt_GetVal()) & 0x3) << 4);
//	Data[0] = Data[0] | (uint8_T)(((Rte_CANTx_PackVoltUVFlt_GetVal()) & 0x3) << 6);
//	Data[1] = Data[1] | (uint8_T)((Rte_CANTx_SOCUFlt_GetVal()) & 0x3);
//	Data[1] = Data[1] | (uint8_T)(((Rte_CANTx_CellOVFlt_GetVal()) & 0x3) << 2);
//	Data[1] = Data[1] | (uint8_T)(((Rte_CANTx_CellUVFlt_GetVal()) & 0x3) << 4);
//	Data[1] = Data[1] | (uint8_T)(((Rte_CANTx_InsResFltLv_GetVal()) & 0x3) << 6);
//	Data[2] = Data[2] | (uint8_T)((Rte_CANTx_CellVoltDiffFlt_GetVal()) & 0x3);
//	Data[2] = Data[2] | (uint8_T)(((0) & 0x3) << 2);
//	Data[2] = Data[2] | (uint8_T)(((Rte_CANTx_SOCOFlt_GetVal()) & 0x3) << 4);
//	Data[2] = Data[2] | (uint8_T)(((Rte_CANTx_SOCJumpFlt_GetVal()) & 0x3) << 6);
//	Data[3] = Data[3] | (uint8_T)((0) & 0x3);
//	Data[3] = Data[3] | (uint8_T)(((Rte_CANTx_HVILFlt_GetVal()) & 0x3) << 2);
//	Data[3] = Data[3] | (uint8_T)((((fltm_enum_ThermRunaway == 3)?1:0) & 0x3) << 4);
//	VCUCAN_Send_Data(0x1802D0F3,Data,8);  //Enqueue
//}


/* --------------- Pcak MessageName: BMS_3 ------------------
            *  ID(Dec)              = 402903283
            *  ID(Hex)              = 0x1803D0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 100
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1803D0F3_BMS_3(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_BatCurr_GetVal());
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_PackVolt_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_linkVolt_GetVal());
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_ptcVolt_GetVal());
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x1803D0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_4 ------------------
            *  ID(Dec)              = 402968819
            *  ID(Hex)              = 0x1804D0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 6
            *  CycleTime            = 100
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1804D0F3_BMS_4(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_InsPRes_GetVal());
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_InsNRes_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_InsRes_GetVal());
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);
	Data[6] = Data[6] | (uint8_T)(((Rte_CANTx_BMSReqPowerOff_GetVal()) & 0x3) << 3);
	Data[6] = Data[6] | (uint8_T)(((Rte_CANTx_BMSSelfChk_GetVal()) & 0x3) << 5);
	Data[6] = Data[6] | (uint8_T)((((bottv_flg_InsuCtlOff>0)?0:1) & 0x1) << 7);
	VCUCAN_Send_Data(0x1804D0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_5 ------------------
            *  ID(Dec)              = 403034355
            *  ID(Hex)              = 0x1805D0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 13
            *  CycleTime            = 100
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1805D0F3_BMS_5(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)((0) & 0x3);
	Data[0] = Data[0] | (uint8_T)(((Rte_CANTx_MaiPosRlySts_GetVal()) & 0x3) << 2);
	Data[0] = Data[0] | (uint8_T)(((Rte_CANTx_PrechgRlySts_GetVal()) & 0x3) << 4);
	Data[0] = Data[0] | (uint8_T)(((Rte_CANTx_PTCRlySts_GetVal()) & 0x3) << 6);
	Data[1] = Data[1] | (uint8_T)((0) & 0x3);
	Data[1] = Data[1] | (uint8_T)(((0) & 0x3) << 2);
	Data[1] = Data[1] | (uint8_T)(((0) & 0x3) << 4);
	Data[1] = Data[1] | (uint8_T)(((bottv_flg_posRlyCtrl) & 0x3) << 6);
	Data[2] = Data[2] | (uint8_T)((bottv_flg_negRlyCtrl) & 0x3);
	Data[2] = Data[2] | (uint8_T)(((0) & 0x3) << 2);
	Data[2] = Data[2] | (uint8_T)(((0) & 0x3) << 4);
	Data[2] = Data[2] | (uint8_T)(((bottv_flg_PrechgRlyCtrl||vewm_flg_prechgRlyCtr) & 0x3) << 6);
	Data[3] = Data[3] | (uint8_T)((bottv_flg_heatRlyCtrl) & 0x3);
	VCUCAN_Send_Data(0x1805D0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_6 ------------------
            *  ID(Dec)              = 403099891
            *  ID(Hex)              = 0x1806D0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 7
            *  CycleTime            = 100
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1806D0F3_BMS_6(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)((Rte_CANTx_BatSts_GetVal()) & 0xF);
	Data[0] = Data[0] | (uint8_T)(((balc_flg_balanceEn) & 0x1) << 4);
	Data[0] = Data[0] | (uint8_T)(((Rte_CANRx_CC1Sts) & 0x1) << 5);
	Data[0] = Data[0] | (uint8_T)(((Rte_CANRx_CCSts) & 0x3) << 6);
	Data[1] = Data[1] | (uint8_T)((Rte_CANTx_DCChgVoltSts_GetVal()) & 0xF);
	Data[1] = Data[1] | (uint8_T)(((Rte_CANTx_ACChgVoltSts_GetVal()) & 0xF) << 4);
	Data[2] = Data[2] | (uint8_T)(0);
	VCUCAN_Send_Data(0x1806D0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_7 ------------------
            *  ID(Dec)              = 403165427
            *  ID(Hex)              = 0x1807D0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 200
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1807D0F3_BMS_7(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_PeakDsgCurr_GetVal());
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_PeakChgCurr_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_ContDsgCurr_GetVal());
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_ContChgCurr_GetVal());
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x1807D0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_8 ------------------
            *  ID(Dec)              = 403230963
            *  ID(Hex)              = 0x1808D0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 200
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1808D0F3_BMS_8(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_PeakDsgPwr_GetVal());
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_PeakChgPwr_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_ContDsgPwr_GetVal());
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_ContChgPwr_GetVal());
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x1808D0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_9 ------------------
            *  ID(Dec)              = 403296499
            *  ID(Hex)              = 0x

            *  ByteCount			= 8
            *  MessageSignalCount   = 5
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1809D0F3_BMS_9(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(bottv_Charge_Times);
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_ChgTime_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)((tempData >> 8) & 0x3);
	Data[3] = Data[3] | (uint8_T)(((0) & 0xF) << 4);

	tempData = (uint32_T)(Rte_CANTx_SOC_GetVal()/10);
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_DispSOC_GetVal()/10);
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x1809D0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_10 ------------------
            *  ID(Dec)              = 403362035
            *  ID(Hex)              = 0x180AD0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 6
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x180AD0F3_BMS_10(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[2] = Data[2] | (uint8_T)(((fltm_enum_insuU > 0)?1:0) & 0x1);
	Data[2] = Data[2] | (uint8_T)(((fltm_num_maxFltNo == 3) & 0x1) << 1);
	Data[2] = Data[2] | (uint8_T)((((fltm_enum_hvilFlt > 0)? 0:1) & 0x1) << 4);
	Data[2] = Data[2] | (uint8_T)(((fltm_flg_ChgPwrDownFlt) & 0x1) << 5);
	Data[2] = Data[2] | (uint8_T)((((fltm_enum_socU > 0)?1:0) & 0x1) << 7);
	Data[7] = Data[7] | (uint8_T)((Rte_CANTx_BATT_TEMP_LAMP_GetVal()) & 0x7);
	VCUCAN_Send_Data(0x180AD0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_11 ------------------
            *  ID(Dec)              = 403427571
            *  ID(Hex)              = 0x180BD0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 6
            *  CycleTime            = 500
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x180BD0F3_BMS_11(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(0);
	Data[1] = Data[1] | (uint8_T)(Rte_CANTx_CellVoltMaxNum_GetVal());

	tempData = (uint32_T)(Rte_mv_CellMaxVol_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);
	Data[4] = Data[4] | (uint8_T)(0);
	Data[5] = Data[5] | (uint8_T)(Rte_CANTx_CellVoltMinNum_GetVal());

	tempData = (uint32_T)(Rte_mv_CellMinVol_GetVal());
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x180BD0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_12 ------------------
            *  ID(Dec)              = 403493107
            *  ID(Hex)              = 0x180CD0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 7
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x180CD0F3_BMS_12(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(0);
	Data[1] = Data[1] | (uint8_T)(Rte_CANTx_CellTempMaxNum_GetVal());
	Data[2] = Data[2] | (uint8_T)(Rte_CANTx_CellTempMax_GetVal());
	Data[3] = Data[3] | (uint8_T)(0);
	Data[4] = Data[4] | (uint8_T)(Rte_CANTx_CellTempMinNum_GetVal());
	Data[5] = Data[5] | (uint8_T)(Rte_CANTx_CellTempMin_GetVal());

	tempData = (uint32_T)(Rte_CANTx_DispSOC_GetVal()*1231/10000);
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x180CD0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_13 ------------------
            *  ID(Dec)              = 419270899
            *  ID(Hex)              = 0x18FD90F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD90F3_BMS_13(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(1));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(2));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(3));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(4));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD90F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_14 ------------------
            *  ID(Dec)              = 419271155
            *  ID(Hex)              = 0x18FD91F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD91F3_BMS_14(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(5));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(6));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(7));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(8));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD91F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_15 ------------------
            *  ID(Dec)              = 419271411
            *  ID(Hex)              = 0x18FD92F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD92F3_BMS_15(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(9));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(10));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(11));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(12));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD92F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_16 ------------------
            *  ID(Dec)              = 419271667
            *  ID(Hex)              = 0x18FD93F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD93F3_BMS_16(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(13));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(14));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(15));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(16));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD93F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_17 ------------------
            *  ID(Dec)              = 419271923
            *  ID(Hex)              = 0x18FD94F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD94F3_BMS_17(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(17));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(18));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(19));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(20));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD94F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_18 ------------------
            *  ID(Dec)              = 419272179
            *  ID(Hex)              = 0x18FD95F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD95F3_BMS_18(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(21));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(22));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(23));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(24));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD95F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_19 ------------------
            *  ID(Dec)              = 419272435
            *  ID(Hex)              = 0x18FD96F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD96F3_BMS_19(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(25));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(26));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(27));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(28));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD96F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_20 ------------------
            *  ID(Dec)              = 419272691
            *  ID(Hex)              = 0x18FD97F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD97F3_BMS_20(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(29));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(30));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(31));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(32));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD97F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_21 ------------------
            *  ID(Dec)              = 419272947
            *  ID(Hex)              = 0x18FD98F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FD98F3_BMS_21(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(33));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(34));
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(35));
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(36));
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FD98F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_22 ------------------
            *  ID(Dec)              = 419287283
            *  ID(Hex)              = 0x18FDD0F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 8
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDD0F3_BMS_22(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(Rte_CANTx_CellTemp_GetVal(0));
	Data[1] = Data[1] | (uint8_T)(Rte_CANTx_CellTemp_GetVal(1));
	Data[2] = Data[2] | (uint8_T)(Rte_CANTx_CellTemp_GetVal(2));
	Data[3] = Data[3] | (uint8_T)(Rte_CANTx_CellTemp_GetVal(3));
	Data[4] = Data[4] | (uint8_T)(Rte_CANTx_CellTemp_GetVal(4));
	Data[5] = Data[5] | (uint8_T)(Rte_CANTx_CellTemp_GetVal(5));
	Data[6] = Data[6] | (uint8_T)(Rte_CANTx_CellTemp_GetVal(6));
	Data[7] = Data[7] | (uint8_T)(Rte_CANTx_CellTemp_GetVal(7));
	VCUCAN_Send_Data(0x18FDD0F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_23 ------------------
            *  ID(Dec)              = 419287539
            *  ID(Hex)              = 0x18FDD1F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 8
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDD1F3_BMS_23(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(0);
	Data[1] = Data[1] | (uint8_T)(0);
	Data[2] = Data[2] | (uint8_T)(0);
	Data[3] = Data[3] | (uint8_T)(0);
	Data[4] = Data[4] | (uint8_T)(0);
	Data[5] = Data[5] | (uint8_T)(0);
	Data[6] = Data[6] | (uint8_T)(0);
	Data[7] = Data[7] | (uint8_T)(0);
	VCUCAN_Send_Data(0x18FDD1F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_26 ------------------
            *  ID(Dec)              = 419297523
            *  ID(Hex)              = 0x18FDF8F3
            *  ByteCount			= 7
            *  MessageSignalCount   = 7
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDF8F3_BMS_26(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(0);
	Data[1] = Data[1] | (uint8_T)(0);
	Data[2] = Data[2] | (uint8_T)(0);
	Data[3] = Data[3] | (uint8_T)(0);
	Data[4] = Data[4] | (uint8_T)(0);
	Data[5] = Data[5] | (uint8_T)(0);
	Data[6] = Data[6] | (uint8_T)(0);
	VCUCAN_Send_Data(0x18FDF8F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_27 ------------------
            *  ID(Dec)              = 419297779
            *  ID(Hex)              = 0x18FDF9F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 6
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDF9F3_BMS_27(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(0);
	Data[1] = Data[1] | (uint8_T)(0);

	tempData = (uint32_T)(0);
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);
	Data[4] = Data[4] | (uint8_T)(bottv_mv_p12V/100);
	Data[5] = Data[5] | (uint8_T)((0) & 0xF);
	Data[7] = Data[7] | (uint8_T)(((1) & 0x1) << 7);
	VCUCAN_Send_Data(0x18FDF9F3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_28 ------------------
            *  ID(Dec)              = 419298035
            *  ID(Hex)              = 0x18FDFAF3
            *  ByteCount			= 8
            *  MessageSignalCount   = 7
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDFAF3_BMS_28(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Pccfg_BatRatedCap);
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Pccfg_BatRatedHighVolt);
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Pccfg_BatRatedEnergy);
	Data[4] = Data[4] | (uint8_T)(tempData);
	Data[5] = Data[5] | (uint8_T)(tempData >> 8);
	Data[6] = Data[6] | (uint8_T)((Rte_CANTx_BatType_GetVal()) & 0xF);
	Data[6] = Data[6] | (uint8_T)(((0) & 0x3) << 4);
	Data[6] = Data[6] | (uint8_T)(((2) & 0x3) << 6);
	Data[7] = Data[7] | (uint8_T)(22);
	VCUCAN_Send_Data(0x18FDFAF3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_29 ------------------
            *  ID(Dec)              = 419298291
            *  ID(Hex)              = 0x18FDFBF3
            *  ByteCount			= 8
            *  MessageSignalCount   = 6
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDFBF3_BMS_29(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(37);
	Data[1] = Data[1] | (uint8_T)(8);
	Data[2] = Data[2] | (uint8_T)(Rte_CANTx_BattSysNum_GetVal());
	Data[3] = Data[3] | (uint8_T)(Rte_CANTx_BattSysSerialNum_GetVal());
	Data[6] = Data[6] | (uint8_T)(8);
	Data[7] = Data[7] | (uint8_T)(4);
	VCUCAN_Send_Data(0x18FDFBF3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_30 ------------------
            *  ID(Dec)              = 419298547
            *  ID(Hex)              = 0x18FDFCF3
            *  ByteCount			= 8
            *  MessageSignalCount   = 3
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDFCF3_BMS_30(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANRx_TatolAllChg_GetVal());
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);
	Data[2] = Data[2] | (uint8_T)(tempData >> 16);

	tempData = (uint32_T)(Rte_CANRx_TatolDsg_GetVal());
	Data[3] = Data[3] | (uint8_T)(tempData);
	Data[4] = Data[4] | (uint8_T)(tempData >> 8);
	Data[5] = Data[5] | (uint8_T)(tempData >> 16);

	tempData = (uint16_T)(Rte_CANRx_sigChgEny_GetVal());
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FDFCF3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_31 ------------------
            *  ID(Dec)              = 419298803
            *  ID(Hex)              = 0x18FDFDF3
            *  ByteCount			= 8
            *  MessageSignalCount   = 8
            *  CycleTime            = 1000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDFDF3_BMS_31(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(0);
	Data[1] = Data[1] | (uint8_T)(0);
	Data[2] = Data[2] | (uint8_T)(0);
	Data[3] = Data[3] | (uint8_T)(0);
	Data[4] = Data[4] | (uint8_T)(0);
	Data[5] = Data[5] | (uint8_T)(0);
	Data[6] = Data[6] | (uint8_T)(0);
	Data[7] = Data[7] | (uint8_T)(0);
	VCUCAN_Send_Data(0x18FDFDF3,Data,8);  //Enqueue
}


/* --------------- Pcak MessageName: BMS_32 ------------------
            *  ID(Dec)              = 419299059
            *  ID(Hex)              = 0x18FDFEF3
            *  ByteCount			= 8
            *  MessageSignalCount   = 6
            *  CycleTime            = 5000
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x18FDFEF3_BMS_32(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};
	Data[0] = Data[0] | (uint8_T)(24);
	Data[1] = Data[1] | (uint8_T)(1);
	Data[2] = Data[2] | (uint8_T)(6);
	Data[3] = Data[3] | (uint8_T)(1);
	Data[4] = Data[4] | (uint8_T)(1);

	tempData = (uint32_T)(Rte_CANTx_SOH_GetVal()*10);
	Data[6] = Data[6] | (uint8_T)(tempData);
	Data[7] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x18FDFEF3,Data,8);  //Enqueue
}

void CAN0_Send_0x18FDFFF3_BMS_33(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	Data[0] = bottv_flg_BalanceCtrlPostion[7]<<7| bottv_flg_BalanceCtrlPostion[6]<<6| bottv_flg_BalanceCtrlPostion[5]<<5| bottv_flg_BalanceCtrlPostion[4]<<4| \
			bottv_flg_BalanceCtrlPostion[3]<<3| bottv_flg_BalanceCtrlPostion[2]<<2| bottv_flg_BalanceCtrlPostion[1]<<1| bottv_flg_BalanceCtrlPostion[0];

	Data[1] = bottv_flg_BalanceCtrlPostion[15]<<7| bottv_flg_BalanceCtrlPostion[14]<<6| bottv_flg_BalanceCtrlPostion[13]<<5| bottv_flg_BalanceCtrlPostion[12]<<4|\
			bottv_flg_BalanceCtrlPostion[11]<<3| bottv_flg_BalanceCtrlPostion[10]<<2| bottv_flg_BalanceCtrlPostion[9]<<1| bottv_flg_BalanceCtrlPostion[8];

	Data[2] = bottv_flg_BalanceCtrlPostion[23]<<7| bottv_flg_BalanceCtrlPostion[22]<<6| bottv_flg_BalanceCtrlPostion[21]<<5| bottv_flg_BalanceCtrlPostion[20]<<4|\
			bottv_flg_BalanceCtrlPostion[19]<<3| bottv_flg_BalanceCtrlPostion[18]<<2| bottv_flg_BalanceCtrlPostion[17]<<1| bottv_flg_BalanceCtrlPostion[16];

	Data[3] = bottv_flg_BalanceCtrlPostion[31]<<7| bottv_flg_BalanceCtrlPostion[30]<<6| bottv_flg_BalanceCtrlPostion[29]<<5| bottv_flg_BalanceCtrlPostion[28]<<4|\
			bottv_flg_BalanceCtrlPostion[27]<<3| bottv_flg_BalanceCtrlPostion[26]<<2| bottv_flg_BalanceCtrlPostion[25]<<1| bottv_flg_BalanceCtrlPostion[24];

	Data[4] = bottv_flg_BalanceCtrlPostion[36]<<4| bottv_flg_BalanceCtrlPostion[35]<<3| bottv_flg_BalanceCtrlPostion[34]<<2| bottv_flg_BalanceCtrlPostion[33]<<1|\
			bottv_flg_BalanceCtrlPostion[32];


	VCUCAN_Send_Data(0x18FDFFF3,Data,8);  //Enqueue
}
/* --------------- Pcak MessageName: BMS_40 ------------------
            *  ID(Dec)              = 402772467
            *  ID(Hex)              = 0x1801D1F3
            *  ByteCount			= 8
            *  MessageSignalCount   = 4
            *  CycleTime            = 500
            *  SendNode             = BMS
            * -----------------------------------------------------------------------*/
void CAN0_Send_0x1801D1F3_BMS_40(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_ACChgVoltReq_GetVal());
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint32_T)(Rte_CANTx_ACChgCurrReq_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);
	Data[4] = Data[4] | (uint8_T)((Rte_CANTx_ACChgEnReq_GetVal()) & 0x3);//(Rte_CANTx_OBCCommSts()
	Data[4] = Data[4] | (uint8_T)(((Rte_CANTx_OBCModeCtr_GetVal()) & 0x3) << 2);//(vewm_enum_SlowChgSts == 2)?0:1
	VCUCAN_Send_Data(0x1801D1F3,Data,8);  //Enqueue
}


void CAN0_Send_0x1801D2F3_BMS_42(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint16_T)(Rte_CANTx_DCChgVoltReq_GetVal());
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint16_T)(Rte_CANTx_DCChgCurrReq_GetVal()+32700);
	Data[2] = Data[2] | (uint8_T)(tempData);
	Data[3] = Data[3] | (uint8_T)(tempData >> 8);
	Data[4] = Data[4] | (uint8_T)((Rte_CANRx_DcChgReq_GetVal()) & 0x3);
	Data[4] = Data[4] | (uint8_T)((1) << 2);

	tempData = (uint16_T)(Rte_CANTx_DispSOC_GetVal()/10);
	Data[5] = Data[6] | (uint8_T)(tempData);
	Data[6] = Data[7] | (uint8_T)(tempData >> 8);
	VCUCAN_Send_Data(0x1801D2F3,Data,8);  //Enqueue
}

void CAN0_Send_0x18FD99F3_BMS_41(void)
{
	uint32_T tempData;
	uint8_T Data[8]={0,0,0,0,0,0,0,0};

	tempData = (uint32_T)(Rte_CANTx_CellVolt_GetVal(37));
	Data[0] = Data[0] | (uint8_T)(tempData);
	Data[1] = Data[1] | (uint8_T)(tempData >> 8);

	tempData = (uint16_T)(Rte_TAB_enum_SOCOcv_GetVal());
	Data[2] = Data[2] | (uint8_T)(tempData >> 8);
	Data[3] = Data[3] | (uint8_T)(tempData);

	tempData = (uint32_T)(bottv_num_saveTime);
	Data[4] = Data[4] | (uint8_T)(tempData >> 24);
	Data[5] = Data[5] | (uint8_T)(tempData >> 16);
	Data[6] = Data[6] | (uint8_T)(tempData >> 8);
	Data[7] = Data[7] | (uint8_T)(tempData);
	VCUCAN_Send_Data(0x18FD99F3,Data,8);  //Enqueue
}



//Unpack

void CAN0_Receive(uint32_T ID, uint8_T *Data)
{
	if(ID == 0x0C01F3D0)
	{
		Rte_CANRx_VCU_HVPwrCmd = (Data[0] == 0x01) ? 1:0;

		Rte_CANRx_VCU_LifeCnt ++;
	}
	if(ID == 0x0C01F8D0)
	{
		Rte_CANRx_tDuty = (uint8_T)((uint16_T)Data[5]);

	}
	if(ID == 0x1801F3D1)
	{
		Rte_CANRx_Obc_ChgSts = Data[0]&0x1;
		Rte_CANRx_Obc_WakeUp = Data[1]&0x01;
		Rte_CANRx_OBC_ChgCurr = (((uint16_T)Data[3]<<8) + Data[2])/10;
		Rte_CANRx_OBC_LifeCnt ++;

		if(Rte_CANRx_Obc_ChgSts == 4)
		{
			Rte_CANRx_OBC_FltSts = 1;
		}
		else
		{
			Rte_CANRx_OBC_FltSts = 0;
		}
	}
	if(ID == 0x1802F3D1)
	{
		Rte_CANRx_OBC_LifeCnt1 ++;
		Rte_CANRx_CCSts = (Data[0]>>4)&0x03;
	}	
	if(ID == 0x0C01F3D0)
	{
		Rte_CANRx_VehicleSpeed = Data[2];
	}
	if(ID == 0x1801F3D2)
	{
		Rte_CANRx_FDC_LifeCnt ++;
		Rte_CANRx_QchgAlow = (Data[4]>>1)&0x01;
		Rte_CANRx_CC1Sts = (Data[0]>>2)&0x01;
		if(Rte_CANRx_CC1Sts == 1)
		{
			bottv_flg_InsuCtlOff = 1;
		}
		else if(Rte_CANRx_CC1Sts == 0)
		{
			bottv_flg_InsuCtlOff = 0;
		}
	}
	if(ID == 0x18FEF4D2)
	{
		Rte_CANRx_FDCSts = Data[0];
		Rte_CANRx_FDCMaiPosRlySts = (Data[1]>>4)&0x03;
	}

}

//////////////////////////Cycle Manager Function///////////////////////
CanMsgType VCANMsg[VcanMsgMax] = {
	{CAN0_Send_0x1801D0F3_BMS_1,100,0,0},
	{CAN0_Send_0x1802D0F3_BMS_2,100,0,0},
	{CAN0_Send_0x1803D0F3_BMS_3,100,0,0},
	{CAN0_Send_0x1804D0F3_BMS_4,100,0,0},
	{CAN0_Send_0x1805D0F3_BMS_5,100,0,0},
	{CAN0_Send_0x1806D0F3_BMS_6,100,0,0},
	{CAN0_Send_0x1807D0F3_BMS_7,200,0,0},
	{CAN0_Send_0x1808D0F3_BMS_8,200,0,0},
	{CAN0_Send_0x1809D0F3_BMS_9,1000,0,0},
	{CAN0_Send_0x180AD0F3_BMS_10,1000,0,0},
	{CAN0_Send_0x180BD0F3_BMS_11,500,0,0},
	{CAN0_Send_0x180CD0F3_BMS_12,1000,0,0},
	{CAN0_Send_0x18FD90F3_BMS_13,1000,0,0},
	{CAN0_Send_0x18FD91F3_BMS_14,1000,0,0},
	{CAN0_Send_0x18FD92F3_BMS_15,1000,0,0},
	{CAN0_Send_0x18FD93F3_BMS_16,1000,0,0},
	{CAN0_Send_0x18FD94F3_BMS_17,1000,0,0},
	{CAN0_Send_0x18FD95F3_BMS_18,1000,0,0},
	{CAN0_Send_0x18FD96F3_BMS_19,1000,0,0},
	{CAN0_Send_0x18FD97F3_BMS_20,1000,0,0},
	{CAN0_Send_0x18FD98F3_BMS_21,1000,0,0},
	{CAN0_Send_0x18FD99F3_BMS_41,1000,0,0},
	{CAN0_Send_0x18FDD0F3_BMS_22,1000,0,0},
	{CAN0_Send_0x18FDD1F3_BMS_23,1000,0,0},
	{CAN0_Send_0x18FDF8F3_BMS_26,1000,0,0},
	{CAN0_Send_0x18FDF9F3_BMS_27,1000,0,0},
	{CAN0_Send_0x18FDFAF3_BMS_28,1000,0,0},
	{CAN0_Send_0x18FDFBF3_BMS_29,1000,0,0},
	{CAN0_Send_0x18FDFCF3_BMS_30,1000,0,0},
	{CAN0_Send_0x18FDFDF3_BMS_31,1000,0,0},
	{CAN0_Send_0x18FDFEF3_BMS_32,5000,0,0},
	{CAN0_Send_0x18FDFFF3_BMS_33,1000,0,0},
	{CAN0_Send_0x1801D1F3_BMS_40,500,0,0},
//	{CAN0_Send_0x1800f400_BMS_41,100,0,0},
	{CAN0_Send_0x1801D2F3_BMS_42,1000,0,0}
};


void TASK_VCANSend(uint16_T cycle)
{
	uint16_T current_time = 0;
	uint8_T k;
	static uint16_T Time_Cnt = 0;

	Time_Cnt ++;
	current_time = Time_Cnt*cycle; //当前时间

	for(k = 0 ; k < VcanMsgMax ; k ++)
	{
		if(*(VCANMsg[k].Caller) != NULL)
		{
			if(VCANMsg[k].Used == 0)
			{
				(*VCANMsg[k].Caller)();
				VCANMsg[k].Used = 1;
				VCANMsg[k].Timestamp = current_time;
				break;
			}
			else if(current_time >= (VCANMsg[k].Cyc + VCANMsg[k].Timestamp))
			{
				(*VCANMsg[k].Caller)();
				VCANMsg[k].Timestamp = current_time;
				break;
			}
			else
			{

			}
		}
	}


	if(current_time >= 60000)
	{
		Time_Cnt = 0;
		for(k = 0 ; k < VcanMsgMax ;k ++ )
		{
			VCANMsg[k].Used = 0;
			VCANMsg[k].Timestamp = 0;
		}
	}

}
//整车can报文Used清零，用于解决busoff恢复之后，没有立即发送整车报文，导致busoff恢复时间不准确
void VCANSend_FirstSetImmediately(void)
{
	//报文立马发送
	uint8_T k;
	for(k = 0 ; k < sizeof(VCANMsg)/sizeof(VCANMsg[0]) ; k ++)
	{
		VCANMsg[k].Used = 0;
	}
}
